import {GetTestBar, GetTestList, UpTestAns} from '@/api/test.js'
const state = {
	testbar: {},
	testlist: {},
	gardes: []
}
const mutations = {
	SET_testbar(state,testbar){
		state.testbar = testbar
	},
	SET_testlist(state,testlist){
		state.testlist = testlist
	},
	SET_grades(state,grades){
		state.grades  = grades
	}
}
const actions = {
	async getTestList({commit},uuid){
		console.log(uuid)
		let result = await GetTestList(uuid);
		console.log("list",result);
		let res = result.data
		if(result.statusCode == 200){
			commit("SET_testlist",res.list);
			return "ok"
		}
	},
	async getTestBar({commit}){
		let result = await GetTestBar();
		// console.log(result);
		let res = result.data
		if(result.statusCode == 200){
			commit("SET_testbar",res.list);
			return "ok"
		}
	},
	async upTestAns({commit},updata){
		console.log(updata)
		let uuid = updata.uuid;
		let list = updata.list
		let result = await UpTestAns({uuid,list});
		console.log(result);
		if(result.statusCode == 200){
			commit("SET_grades",result.data.score)
			return result.data
		}
		
	},
}


const getter = {

}

export default {
	state,
	actions,
	mutations,
	getter
}
